package com.xianggu.mapper;

import com.xianggu.demo.dto.UserDto;
import com.xianggu.mybatis.annotation.*;
import com.xianggu.mybatis.paging.Page;

import java.util.List;
import java.util.Map;

/**
 * @author chengjy
 * @date 2025/3/8
 */
@Mapper
public interface UserMapper {
    @Select("select * from els_subaccount_info where id = #{id}")
    UserDto getUserInfo(String id);

    @Select("select * from els_subaccount_info where create_by = #{condition}")
    List<UserDto> queryUserList(String condition);

    @Select("select * from els_subaccount_info ")
    List<UserDto> quertList(String condition);

    @Insert("Insert into els_subaccount_info (id,realname,password,els_account) values (#{id},#{realname},#{password},#{elsAccount})")
    String saveUser(UserDto userDto);

    @Select("select * from els_subaccount_info where create_by = #{id}")
    Page<UserDto> getUserList(String id, Page<UserDto> page);


    //    @Select("select * from els_subaccount_info where create_by = #{id}")
    List<Map<String, Object>> getUserListMap(@Param("id") String id);

    @Select("select * from els_subaccount_info")
    Page<UserDto> getInitList(Page<UserDto> page);

    @Select("select * from els_subaccount_info where id = #{id}")
    UserDto getUserById(String id);

    @Update("UPDATE els_subaccount_info SET email = #{email} , password = #{password} , phone = #{phone} , realname = #{realname} , status = #{status} WHERE id = #{id}")
    String updateById(UserDto userDto);

    @Delete("DELETE FROM els_subaccount_info WHERE id = #{id}")
    String deleteById(String id);

    @Select("SELECT * FROM els_subaccount_info WHERE (realname like CONCAT('%',#{searchKey},'%') || phone like CONCAT('%',#{searchKey}))")
    Page<UserDto> searchContidion(Page<UserDto> page, Map<String, Object> param);
}
